<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//Route::get('/','App\Http\Controllers\Admin\HomeController@index');

//Route::get('/','Admin\HomeController@index');
//在laravel回调函数中使用类型约束有2个好处一个是限制了传入这个
Route::get('/','Admin\RouteController@make');

//模块儿管理

//在线教育模块儿
//include 'moduleroute/eduroute.php';


//文章系统

//新增用户路由组
//新增用户路由组
Route::group(['namespace'=>'User'],function (){
    Route::get('login','LoginController@login')->name('login');
    Route::post('login','LoginController@store')->name('login');
    Route::get('logout','LoginController@logout')->name('logout');
    //注册路由
    Route::get('user/register','RegisterController@create')->name('register');
    Route::post('user/register','RegisterController@store')->name('register');
    //重置密码路由
    Route::get('user/resetpassword','ResetPasswordController@index')->name('user.resetpassword');
    Route::post('user/resetpassword','ResetPasswordController@update')->name('user.resetpassword');
});

//公共路由

\App\Models\AdminModule::get()->each(function ($module){
//    each 方法将迭代集合中的内容并将其传递到回调函数中
        $file = str_replace('/','\\',base_path('app/Http/Controllers/').$module['module'].'/config/routes/web.php');
        //通过&&连接符,当前成立为真的时候后面才会执行,否则后面就不会执行.
        is_file($file)&&include $file;
});


